package com.uchedao.seller.ui.car.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.uchedao.seller.R;
import com.uchedao.seller.http.entity.CarForSaleBean;
import com.uchedao.seller.ui.adapter.CommonAdapter;
import com.uchedao.seller.ui.adapter.ViewHolder;
import com.uchedao.seller.ui.car.publish.PublishBidRuleActivity;
import com.uchedao.seller.util.Arith;

import java.util.List;

/**
 * Created by hang on 2015/10/23.
 */
public class CarForSaleAdapter extends CommonAdapter<CarForSaleBean> {
    public CarForSaleAdapter(Context context, List<CarForSaleBean> data) {
        super(context, data, R.layout.item_car_for_sale);
    }

    @Override
    public void conver(ViewHolder holder, final CarForSaleBean item, int position) {
        holder.getView(R.id.btnPromote).setVisibility(View.GONE);
        holder.getView(R.id.btnCutPrice).setVisibility(View.GONE);
        holder.getView(R.id.btnViewPrice).setVisibility(View.GONE);

        holder.setImageByURL(R.id.ivForSaleItemPic, item.getCover_photo());
        holder.setText(R.id.tvForSaleItemTitle, item.getTitle());
        holder.setText(R.id.tvForSaleItemKmDate, Arith.div(item.getKilometer(),10000, 4)+"万公里 "+item.getCard_time());
        holder.setText(R.id.tvForSaleItemPrice, Arith.div(item.getPrice(),10000, 4)+"");

        holder.getView(R.id.btnSubmit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent it = new Intent(mContext, PublishBidRuleActivity.class);
                it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                it.putExtra("carId", item.getId());
                mContext.startActivity(it);
            }
        });
    }
}
